package electricity;

import generic.Particle;

public class CoulombsLaw {

	public static void main(String[] args) {
		Particle p = new Particle(700, 80, 1, 1, 1);
		p.setX(0);
		p.setY(0);
		
		
		Particle q = new Particle(700, -4, 1, 1, 1);
		p.setX(1);
		p.setY(1);
		
		System.out.println(getAttraction(p, q));
	}
	
	/**
	 * Gets the attraction of two particles in Coulombs
	 * @return	double	Coulomb value of attraction
	 */
	public static double getAttraction(Particle p1, Particle p2) {
		double k = 9 * Math.pow(10, 9);
		
		double q1 = p1.getCharge();
		double q2 = p2.getCharge();
		
		double d = Math.sqrt(Math.pow(p1.getX()-p2.getX(),2)+Math.pow(p1.getY()-p2.getY(),2)); //Distance
		
		double F = k*((q1*q2)/Math.pow(d, 2));
		
		return F;
	}
}
